import React, { Component } from 'react';
class gjhs1 extends Component {
  constructor(props) {
    super(props);
    this.state = { 

    }
  }
  render() { 
    return ( 
      <div>
        <form onSubmit={this.handleSubmit}>
          账号：<input onChange={this.seveForm('username')} type="text" name="username"></input>
          密码：<input onChange={this.seveForm('password')} type="password" name="password"></input>
          <button>登陆</button>
        </form>
      </div>
    );
  }

  // 如果chenge 事件带参数   需要return 一个函数   次方法为高阶函数
  seveForm = (dataType) => {
    console.log(dataType)
    return (event) => {
      console.log(event.target.value)
      this.setState({
        [dataType]:event.target.value
      })
    }
  }

  handleSubmit = () => {
    
  }
}
 
export default gjhs1;